package com.zhongxi.guoyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zhongxi.guoyuan.R;

import java.util.List;

/**
 * Created by Administrator on 2016/11/30.
 */

public class AddressAdapter extends BaseAdapter{

    private List<String> list;
    private LayoutInflater mLayoutInflater;

    public AddressAdapter(Context context, List<String> list) {
        this.mLayoutInflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.item_address, parent, false);
            holder.tvPeople = (TextView) convertView.findViewById(R.id.tvPeople);
            holder.tvPhone = (TextView) convertView.findViewById(R.id.tvPhone);
            holder.tvAddress = (TextView) convertView.findViewById(R.id.tvAddress);
            holder.ivCheck = (ImageView) convertView.findViewById(R.id.ivSelect);
            holder.relaEdit = (RelativeLayout) convertView.findViewById(R.id.relaEdit);
            holder.relaDelete = (RelativeLayout) convertView.findViewById(R.id.relaDelete);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.ivCheck.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
        return convertView;
    }

    class ViewHolder{
        private TextView tvPeople;
        private TextView tvPhone;
        private TextView tvAddress;
        private RelativeLayout relaEdit;
        private RelativeLayout relaDelete;
        private ImageView ivCheck;
    }
}
